package cn.virens.service.impl.platform.generator.common;

import cn.hutool.core.util.StrUtil;

public class TableFileUtil {

	public static String controlFile(String root, TableInfoEx info) {
		return String.format("%s/%s/%s/%s/%sContorller.java", root, p(info.getPackageBase()), p(info.getPackageControl()), info.getControlPath(), info.getControlName());
	}

	public static String serviceFile(String root, TableInfoEx info) {
		return String.format("%s/%s/%s/%s/%sService.java", root, p(info.getPackageBase()), p(info.getPackageService()), info.getModelPath(), info.getModelName());
	}

	public static String serviceImplFile(String root, TableInfoEx info) {
		return String.format("%s/%s/%s/%s/%sServiceImpl.java", root, p(info.getPackageBase()), p(info.getPackageServiceImpl()), info.getModelPath(), info.getModelName());
	}

	public static String pageFile(String root, TableInfoEx info, String name) {
		return String.format("%s/%s/%s.html", root, info.getControlMapping(), name);
	}

	private static String p(String _package) {
		return StrUtil.replace(_package, ".", "/");
	}
}
